package com.example.photography.fragment;

import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.photography.Activity.message.Message_like_and_save;
import com.example.photography.R;
import com.example.photography.adapter.message.MessageChatAdatper;
import com.example.photography.bean.MessagechatBean;
import com.example.photography.common.BaseFragment;
import com.example.photography.fragment.im.ConversationListFragment;
import com.example.photography.util.Util;
import com.loopj.android.http.RequestParams;

import butterknife.BindView;

public class MessageFragment extends BaseFragment {


    @BindView(R.id.tv_message_createchat)
    TextView tvMessageCreatechat;
    @BindView(R.id.iv_praise_new)
    ImageView ivPraiseNew;
    @BindView(R.id.ll_praise)
    LinearLayout llPraise;
    @BindView(R.id.iv_attention_new)
    ImageView ivAttentionNew;
    @BindView(R.id.ll_attention)
    LinearLayout llAttention;
    @BindView(R.id.iv_comment_new)
    ImageView ivCommentNew;
    @BindView(R.id.ll_comment)
    LinearLayout llComment;
    @BindView(R.id.push_content)
    TextView pushContent;
    @BindView(R.id.push_date)
    TextView pushDate;
    @BindView(R.id.sys_content)
    TextView sysContent;
    @BindView(R.id.sys_date)
    TextView sysDate;
    @BindView(R.id.fl_chat)
    FrameLayout flChat;
    private MessagechatBean messagechatBean;
    private MessageChatAdatper messageChatAdatper;


    @Override
    protected RequestParams getParams() {
        return null;
    }

    @Override
    protected String getUrl() {
        return null;
    }

    @Override
    protected void initData(String content) {
        initView();
    }

    private void initView() {
        String content = Util.getJson(getActivity(), "message_chat.json");
        if (TextUtils.isEmpty(content)) {//数据为空
            return;
        }
        JSONObject jsonObject = JSON.parseObject(content);
        String data = jsonObject.getString("data");
        messagechatBean = JSONObject.parseObject(data, MessagechatBean.class);
        //会话列表
        getParentFragmentManager().beginTransaction()
                .replace(R.id.fl_chat, new ConversationListFragment(), "chat_room_contact")
                .commit();
//        messageChatAdatper = new MessageChatAdatper(getActivity(),messagechatBean);
//        rcMessage.setAdapter(messageChatAdatper);
//        //设置布局管理者
//        rcMessage.setLayoutManager(new GridLayoutManager(getActivity(),1));
        initListen();

    }

    private void initListen() {
        llPraise.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getActivity(), Message_like_and_save.class);
                startActivity(intent);
            }
        });
    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_message1;
    }
}
